home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2002 January / maximum-cd-2002-01.iso / Files / Mechwarrior 4 Mapping / MW4Editor.exe / content / ABLScripts / GenericScripts / Generic_UnarmedSentry.abl < prev    next >
Encoding:
Text File  |  2001-07-16  |  4.6 KB  |  160 lines

  1.  
  2. //------------------------------------------------------------------
  3. // NOTE: The fsm name below MUST be changed in order for the
  4. // script to be considered a unique entity!
  5.  
  6. fsm Generic_UnarmedSentry : integer;
  7.  
  8.  
  9. //------------------------------------------------------------------
  10.  
  11. // Generic_UnarmedSentry:
  12. //   Stands still and runs from enemies.
  13.  
  14. // NOTE: this script requires a CombatAI (or MechAI) to work properly!!!
  15.  
  16. //------------------------------------------------------------------
  17.  
  18.  
  19.  
  20. //------------------------------------------------------------------
  21. //     Constants
  22. //------------------------------------------------------------------
  23.  
  24.     const
  25.         #include_ <content\ABLScripts\mwconst.abi>
  26.  
  27. //------------------------------------------------------------------
  28. //     Types
  29. //------------------------------------------------------------------
  30.  
  31.     type
  32.         #include_ <content\ABLScripts\mwtype.abi>
  33.     
  34.  
  35. //------------------------------------------------------------------
  36. //     Variables
  37. //------------------------------------------------------------------
  38.  
  39.     var
  40.         static integer            fleeRange;            // At what range do I start running?
  41.         static integer            stopFleeingRange;    // After I've fled, at what range can I forget about my enemy and return to sentry duty?
  42.  
  43.         static integer            piloting;            // Piloting skill
  44.         static integer            gunnery;            // Gunnery skill/chance to hit
  45.         static real                minDelay;            // Minimum amount of time I will wait between shots once a weapon is reloaded
  46.         static real                maxDelay;            // Maximum amount of time I will wait between shots once a weapon is reloaded
  47.         static integer             eliteLevel;            // Elite level.  This helps determine tactics, defensive manuevers, opportunity fire
  48.                                                     // and other things.  It indicates a general level of combat experience.
  49.         static integer            attackThrottle;        // My attack throttle
  50.  
  51.          static integer            isShotRadius;        // How far away from me will I detect an enemy shot?
  52.  
  53.         static integer             attackSound;        // The attack sound I play when I first attack
  54.         static integer             deathSound;            // The sound I play when I die
  55.         
  56.         static integer            mood;                // My default mood.
  57.  
  58.         static integer            fleeSpeed;            // How fast I flee
  59.  
  60.         static integer            takeOffDistance;    // My take-off distance if I'm an airplane (ignored if not an airplane)
  61.  
  62. //------------------------------------------------------------------
  63. //     Init: my initialization function
  64. //------------------------------------------------------------------
  65.  
  66. function Init;
  67.     code
  68.         // script-specific variables
  69.         fleeRange        = 500;
  70.         stopFleeingRange    = 1000;
  71.         fleeSpeed        = 600;
  72.         takeOffDistance    = 150;
  73.  
  74.         // driver settings
  75.         piloting        = 50;
  76.         gunnery            = 30;
  77.         minDelay        = 1.5;
  78.         maxDelay        = 3.0;
  79.         eliteLevel        = 30;
  80.         attackThrottle    = 80;
  81.         isShotRadius    = 120;
  82.         attackSound        = -1; // no sound
  83.         deathSound        = -1; // no sound
  84.         mood            = NEUTRAL_START;
  85.  
  86. endfunction;
  87.  
  88. //------------------------------------------------------------------
  89. //    StartState: my initial state
  90. //------------------------------------------------------------------
  91.  
  92. state StartState;
  93.  
  94.     code
  95.         SetFiringDelay            (ME,minDelay,maxDelay);
  96.         SetIgnoreFriendlyFire    (ME,true);
  97.         SetIsShotRadius            (ME,isShotRadius);
  98.         SetEntropyMood            (ME,mood);
  99.         SetCurMood                (ME,mood);
  100.         SetSkillLevel            (ME,piloting,gunnery,eliteLevel);
  101.         SetAttackThrottle        (ME,attackThrottle);
  102.                 
  103.         if (orderTakeOff(takeOffDistance) == true) then
  104.             trans WaitState;
  105.         endif;
  106.  
  107. endstate;            
  108.  
  109. //------------------------------------------------------------------
  110. //    WaitState: wait for someone to come near
  111. //------------------------------------------------------------------
  112.  
  113. state WaitState;
  114.     code
  115.         OrderMoveLookOut;
  116.         if (FindEnemy(fleeRange,FT_DEFAULT)) then
  117.             ClearMoveOrder(ME);
  118.             trans FleeState;
  119.         endif;
  120.  
  121. endstate;
  122.  
  123. //------------------------------------------------------------------
  124. //    FleeState: run away from my target
  125. //------------------------------------------------------------------
  126.  
  127. state FleeState;
  128.     code
  129.         if (LeaveAttackState(stopFleeingRange)) then
  130.             ClearMoveOrder(ME);
  131.             SetTarget(ME,NO_UNIT);
  132.             trans WaitState;
  133.         endif;
  134.  
  135.         if (attackSound <> -1) then    
  136.             PlaySoundOnce(attackSound);
  137.         endif;
  138.  
  139.         OrderMoveFlee(GetTarget(ME),fleeSpeed);
  140.  
  141. endstate;
  142.  
  143. //------------------------------------------------------------------
  144. //    DeadState: OK, I kicked the bucket.
  145. //------------------------------------------------------------------
  146.  
  147. state DeadState;
  148.     code
  149.         if (deathSound <> -1) then    
  150.             PlaySoundOnce(deathSound);
  151.         endif;        
  152.  
  153.         orderDie;
  154.  
  155. endstate;
  156.  
  157.  
  158. endfsm.
  159.  
  160.